﻿CREATE TABLE [dbo].[Unit] (
    [Id]           UNIQUEIDENTIFIER CONSTRAINT [DF_Unit_Id] DEFAULT (newid()) NOT NULL,
    [Name]         NVARCHAR (128)   NOT NULL,
    [ShortName]    NVARCHAR (8)     NOT NULL,
    [DateActive]   DATE             CONSTRAINT [DF_Unit_DateActive] DEFAULT (getdate()) NOT NULL,
    [DateInactive] DATE             NULL,
    [CompanyId]    UNIQUEIDENTIFIER NOT NULL,
    CONSTRAINT [PK_Unit] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Unit_1]
    ON [dbo].[Unit]([CompanyId] ASC, [ShortName] ASC);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Unit]
    ON [dbo].[Unit]([CompanyId] ASC, [Name] ASC);

